<?php 

class Model_ProductReportsComment extends Model{

	function __construct(){

	}

	/* 獲得報告回覆列表資料
	* $reportsId int ReportsID
	* $orderby		string	 	字段名 desc 或 字段名 asc
	* $page		int			當前頁數
	* $size		int			獲取個數
	* return		array		資料數組
	*/
	function getReportsCommentList($reportsId=0,$orderby="TB1.id desc",$page = 1, $size = 3){
		
		$where="TB1.status=1 and TB1.topid=0 ";
		if(intval($reportsId)) $where.=" and TB1.oid=".intval($reportsId);

		$param = array();
		$param['field'] = "TB1.*,TB2.photo,TB2.username ";
		$param['where'] = $where;
		$param['order'] = $orderby; //"id asc"
		$param['group'] = "";
		$param['limit'] = "";
		$param['pagesize'] = $size;
		$param['page'] = $page;
		$param['join'] = "LEFT JOIN member_imore";
		$param['on'] = "TB1.mid = TB2.id";
		$data = db_query_hash('product_reports_comment',$param);
		return $data;

	}

	/* 獲得SubComment列表資料
	* $topid int 上一層回覆ID
	* $orderby		string	 	字段名 desc 或 字段名 asc
	* $page		int			當前頁數
	* $size		int			獲取個數
	* return		array		資料數組
	*/
	function getReportsSubCommentList($topid,$orderby="TB1.id desc",$page = 1, $size = 5){
		
		$where="TB1.status=1";
		if(intval($topid)) {
			$where .=" and TB1.topid=".intval($topid);
		}else{
			 return false;
		}
		
		$param = array();
		$param['field'] = "TB1.*,TB2.photo,TB2.username";
		$param['where'] = $where;
		$param['order'] = $orderby; //"id asc"
		$param['group'] = "";
		$param['limit'] = "";
		$param['pagesize'] = $size;
		$param['page'] = $page;
		$param['join'] = "LEFT JOIN member_imore";
		$param['on'] = "TB1.mid = TB2.id";
		$subComment = db_query_hash('product_reports_comment',$param);

		return $subComment;

	}

}
?>